package com.xjh;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class CORSConfiguration {
    @Bean
    public WebMvcConfigurer corsConfigurer() {
        return new WebMvcConfigurerAdapter() {
            @Override
            public void addCorsMappings(CorsRegistry registry) {


                String[] allowDomain = {"https://edu-web.ecan-sports.com","http://192.168.10.2:8900","http://47.111.13.238/edu", "http://192.168.10.6:8900","http://192.168.1.2:8900","http://192.168.3.32:8900"};
                registry.addMapping("/**")
                        .allowedOrigins(allowDomain)
                        .allowCredentials(true) // 只设置一次
                        .allowedMethods("*")
                        .allowedHeaders("*");

            }
        };
    }
}
